#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;

const int N=1e6+7;

LL n,cnt;
int a[N];
int b[N];

void merge(int l,int r){
	if(l==r)return ;
	int mid=l+((r-l)>>1);
	merge(l,mid);
	merge(mid+1,r);
	
	int ll=l,rr=mid+1;
	int cur=l;
	
	while(ll<=mid&&rr<=r)
	{
		if(a[ll]<=a[rr]){
			b[cur++]=a[ll++];
		} else {
			b[cur++]=a[rr++];
			cnt+=mid-ll+1;
		}
	}
	while(ll<=mid)
		b[cur++]=a[ll++];
	while(rr<=r)
		b[cur++]=a[rr++];
	
	for(int i=l;i<=r;i++){
		a[i]=b[i];
	}
	
	return ;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	merge(1,n);
	cout << cnt << endl;
}

